package day230410;

import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/4/11 18:29
 */
public class Main01 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            int numberOfBottles = scan.nextInt(); // 瓶子数量
            if (numberOfBottles == 0) {
                continue;
            }
            int conversionQuantity = 0;
            while (numberOfBottles > 1) {
                int residue = numberOfBottles % 3; // 剩余瓶子数量
                int tempConversion = numberOfBottles / 3;
                conversionQuantity += numberOfBottles / 3; // 兑换数量
                numberOfBottles = tempConversion + residue;
                if (numberOfBottles == 2) {
                    // 如果剩余瓶子为2个， 可以借一个
                    conversionQuantity++;
                    break;
                }
            }
            System.out.println(conversionQuantity);
        }
        scan.close();
    }
}